package com.ruoyi.web.controller.ziran;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ziran.domain.ZrPaperUserItem;
import com.ruoyi.ziran.service.IZrPaperUserItemService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 用户答题详情Controller
 * 
 * @author ruoyi
 * @date 2024-10-29
 */
@Controller
@RequestMapping("/ziran/zrPaperUserItem")
public class ZrPaperUserItemController extends BaseController
{
    private String prefix = "ziran/zrPaperUserItem";

    @Autowired
    private IZrPaperUserItemService zrPaperUserItemService;

    //@RequiresPermissions("ziran:zrPaperUserItem:view")
    @GetMapping()
    public String zrPaperUserItem()
    {
        return prefix + "/zrPaperUserItem";
    }

    /**
     * 查询用户答题详情列表
     */
    //@RequiresPermissions("ziran:zrPaperUserItem:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZrPaperUserItem zrPaperUserItem)
    {
        startPage();
        List<ZrPaperUserItem> list = zrPaperUserItemService.selectZrPaperUserItemList(zrPaperUserItem);
        return getDataTable(list);
    }

    /**
     * 导出用户答题详情列表
     */
    //@RequiresPermissions("ziran:zrPaperUserItem:export")
    @Log(title = "用户答题详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZrPaperUserItem zrPaperUserItem)
    {
        List<ZrPaperUserItem> list = zrPaperUserItemService.selectZrPaperUserItemList(zrPaperUserItem);
        ExcelUtil<ZrPaperUserItem> util = new ExcelUtil<ZrPaperUserItem>(ZrPaperUserItem.class);
        return util.exportExcel(list, "用户答题详情数据");
    }

    /**
     * 新增用户答题详情
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存用户答题详情
     */
    //@RequiresPermissions("ziran:zrPaperUserItem:add")
    @Log(title = "用户答题详情", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZrPaperUserItem zrPaperUserItem)
    {
        return toAjax(zrPaperUserItemService.insertZrPaperUserItem(zrPaperUserItem));
    }

    /**
     * 修改用户答题详情
     */
    //@RequiresPermissions("ziran:zrPaperUserItem:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ZrPaperUserItem zrPaperUserItem = zrPaperUserItemService.selectZrPaperUserItemById(id);
        mmap.put("zrPaperUserItem", zrPaperUserItem);
        return prefix + "/edit";
    }

    /**
     * 修改保存用户答题详情
     */
    //@RequiresPermissions("ziran:zrPaperUserItem:edit")
    @Log(title = "用户答题详情", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZrPaperUserItem zrPaperUserItem)
    {
        return toAjax(zrPaperUserItemService.updateZrPaperUserItem(zrPaperUserItem));
    }

    /**
     * 删除用户答题详情
     */
    //@RequiresPermissions("ziran:zrPaperUserItem:remove")
    @Log(title = "用户答题详情", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zrPaperUserItemService.deleteZrPaperUserItemByIds(ids));
    }
}
